#include "Savings.hpp"
#include "Tournee.hpp"

Savings::Savings(VRPTW&  inVRPTW)
    : Solver(inVRPTW), saSolution(inVRPTW)
{}

Savings::~Savings()
{}


void    Savings::execute() EXC_THROWER()
{
    // construire la solution avec une tournee par client
    
    TourneeEvalResult   evalres;
    
    for (unsigned i = 0 ; i < soVRPTW.size() ; i++)
    {
        Tournee&    t = saSolution[i];
        t.insertClient(Tournee::INSERT_BEGIN, i);
        //t.insertClient(Tournee::INSERT_END, (i + 1) % soVRPTW.size());
        //t.erase((i + 1) % soVRPTW.size());
        t.eval(&evalres);
        if (!evalres.erValable)
            EXC_THROW("savings initialization construction : invalid tournee !!");
        saSolution.validateTournee(i);
    }
    
    std::cout << saSolution.toString() << std::endl;
}
